package hello

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"elem_svc/elem"

	"github.com/zeromicro/go-zero/core/logx"
)

type Login1Logic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewLogin1Logic(ctx context.Context, svcCtx *svc.ServiceContext) *Login1Logic {
	return &Login1Logic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *Login1Logic) Login1(req *types.Login1Request) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	login1, err := l.svcCtx.ElemRpc.Login1(l.ctx, &elem.Login1Request{
		Mobile:   req.Mobile,
		SendCode: req.SendCode,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "登录成功",
		Data:    login1,
		Code:    200,
	}, nil
}
